-# locals: instance
-set all_object_people = instance.object_people

%li.tab-title-holder
  .item-main
    .item-title
      .row-fluid
        .span12
          .js-list-container-title
            %h3.tab-title
              People
              %span.grc-badge{ 'class': '={ "no-object" if not all_object_people|length else "" }' }
                (={ all_object_people|length })
              %a.pull-right{ 'href': 'list_edit_flow_object_people_path(object_type: instance.class.name, object_id: instance.id)', 'data-toggle': 'modal-ajax-relationship-selector', 'data-modal-reset': 'reset', 'data-list-target': '#personList', 'data-modal-class': 'modal-wide', 'rel': 'tooltip', 'data-placement': 'left', 'title': 'Link People' }
                %i.grcicon-link

  %script#person_list_item{ 'type': 'text/html', 'data-member': 'object_person' }
    %li.controlSlot{ 'data-id': '<%= person.id %>' }
      .item-main
        .item-title
          .row-fluid
            .span12
              .oneline
                %span.addition-info
                  %a{ 'href': 'mailto:<%= person.email %>', 'rel': 'tooltip', 'title': '<%= person.email %>' }
                    <%= person.name && person.name.trim() || person.email %>
                  %span.role
                    <%= role %>

  %ul#personList.tree-structure{ 'data-template-id': 'person_list_item' }
    -for object_item in all_object_people
      -set item = object_item.person
      %li{ 'data-id': '={ item.id }' }
        .item-main
          .item-title
            .row-fluid
              .span12
                .oneline
                  %span.addition-info
                    -if item.name and item.email
                      %a{ 'href': 'mailto:={ item.email }', 'target': '_blank', 'rel': 'tooltip', 'title': '={ item.email }' }
                        =item.name
                    -elif item.name
                      =item.name
                    -elif item.email
                      %a{ 'href': 'mailto:={ item.email }', 'target': '_blank' }
                        =item.email
                    -else
                      ="&nbsp".html_safe
                    %span.role
                      =object_item.role
